package com.example.com.skills_utf8;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;

import cn.digirun.service.aidl.IA;
import cn.digirun.service.aidl.IService;

public class _71Activity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity__71);


        // 得到远程的服务
        Intent intent = new Intent();
        intent.setPackage("cn.digirun.service");
        intent.setAction("cn.digirun.service.1");
        startService(intent);


        bindService(intent, new ServiceConnection() {
            @Override
            public void onServiceConnected(ComponentName name, IBinder service) {
                Log.e("AIDL", "" + service);
                IService iService = IService.Stub.asInterface(service);

                try {
                    IA ia = IA.Stub.asInterface(iService.getA());
                    int result = ia.fuc(1,1);
                    Log.e("AIDL", "result:"+result);
                } catch (RemoteException e) {
                    e.printStackTrace();
                }

            }

            @Override
            public void onServiceDisconnected(ComponentName name) {

            }
        }, Context.BIND_AUTO_CREATE);




    }
}
